
<template>
    <div>
        <table>
            <tr>
                <td>ID</td>
                <td>商品名称</td>
                <td>商品价格</td>
                <td>商品状态</td>
                <td>商品添加时间</td>
            </tr>
            <tr v-for="(i,j) in googs_list" :key="j">
                <td>{{i.id}}</td>
                <td>{{i.name}}</td>
                <td>{{i.price}}</td>
                <td>{{i.status}}</td>
                <td>{{i.addtime}}</td>
            </tr>
        </table>
        <p>
            <button @click="first_page()">首页</button>
            <button @click="up_page()">上一页</button>
            <button v-for="p in gooslist" :key="p" @click="get_page(p)">{{p}}</button>
            <button @click="down_page()">下一页</button>
            <button @click="last_page()">尾页</button>
        </p>
    </div>
</template>

<script>
import axios from 'axios'
export default {
    name:"gshow",
    data(){
        return{
            gooslist:[],
            googs_list:[],
            sf:"",
            p:1
        }
    },
    method(){
        this.axios({
            url:"/api//",
            method:"get",
        }).then(res=>{
            this.gooslist =res.data.data
        })
    },
    methods:{
         get_info(){
            var data={"page":this.p}
            console.log(111,data)
            this.axios({
                url:'/http://127.0.0.1:8000/zks/gshow/',
                method:'get',
                params:data
            }).then(res=>{
                console.log(res.data)
                this.gooslist = res.data.gooslist;
                this.googs_list = res.data.data;
                this.sf = res.data.sf;
            })
        },
        get_page(p){
            console.log(p)
            this.p = p
            this.get_info()
        },
        first_page(){
            this.p = 1
            this.get_info()
        },
        up_page(){
            if(this.p>1){
                this.p -=1
                this.get_info()
            }else{
                this.p = 1
                this.get_info()
            }
        },
        down_page(){
            if(this.p>=this.sf){
                this.p = this.sf
                this.get_info()
            }else{
                this.p += 1
                this.get_info()
            }
        },
        last_page(){
            this.p = this.sf

            this.get_info()
        },
        
    },
    created() {
            this.get_info()
        },
    
}
</script>

<style>

</style>
